import { Component, OnInit } from '@angular/core';
import { uniqueId } from 'lodash';
import { OptionItem } from '@iux/live';

@Component({
  selector: 'app-demo8',
  templateUrl: './demo8.component.html',
  styles: []
})
export class Demo8Component implements OnInit {

  data: OptionItem[];
  value;
  constructor() { }

  ngOnInit() {
    this.initData();
  }

  initData() {
    this.data = Array.from({length: 10}).map((item, key) => {
      return this.initUser(key, key % 2 !== 0);
    });

    this.value = this.data[0];
  }

  initUser(key: number, disabled: boolean) {
    return {
      id: uniqueId('uid'),
      label: `user${key}`,
      age: 10 + key,
      expand: false,
      random: parseInt(Math.random() * 100 + ''),
      disabled: disabled,
      isLeaf: true
    };
  }

  change(value) {
    console.log('change', value)
  }
}
